package com.ninetaildemonfox.zdl.socialproject.utils.dialog.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ninetaildemonfox.zdl.socialproject.R;

import java.util.List;
import java.util.Map;

/**
 * 创建人： Nine tails fox
 * 创建时间： 2019/7/19
 * 功能描述：
 * 联系方式：1037438704@qq.com
 *
 * @author NineTailDemonFox
 */

public class BottomAdapter extends BaseQuickAdapter<Map<String, String>, BaseViewHolder> {
    private int type;

    public BottomAdapter(int layoutResId, @Nullable List<Map<String, String>> data) {
        super(layoutResId, data);
    }

    public BottomAdapter(int list_bottom) {
        super(list_bottom);
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, Map<String, String> data) {
        TextView textContext = helper.itemView.findViewById(R.id.text_context);
        textContext.setText(data.get("name"));
        if (type == 1) {
            Drawable drawable = null;
            if (data.get("count").equals("1")) {
                drawable = mContext.getResources().getDrawable(R.mipmap.ic_rectangle_false);
            } else if (data.get("count").equals("2")) {
                drawable = mContext.getResources().getDrawable(R.mipmap.ic_rectangle_true);
            }
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            textContext.setCompoundDrawables(null, null, drawable, null);
        } else if (type == 2 || type == 4) {
            if (data.get("count").equals("1")) {
                textContext.setBackgroundResource(R.drawable.shape_drawable_my_text_bg_false);
                textContext.setTextColor(mContext.getResources().getColor(R.color.color_999999));
            } else if (data.get("count").equals("2")) {
                textContext.setTextColor(mContext.getResources().getColor(R.color.colorWhite));
                textContext.setBackgroundResource(R.drawable.shape_drawable_my_text_bg);
            }
        } else if (type == 3) {
            Drawable drawable = null;
            if (data.get("count").equals("1")) {
                drawable = mContext.getResources().getDrawable(R.mipmap.ic_circular_false);
            } else if (data.get("count").equals("2")) {
                drawable = mContext.getResources().getDrawable(R.mipmap.ic_circular_true);
            }
            drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
            textContext.setCompoundDrawables(null, null, drawable, null);
        }
    }
}